<template>
	<view class="relative analysis" v-show="visible" style="background-color: #F5F5F5;">
		<!-- :default-page-size="9999" -->
		<!-- v-if="token && !userInfo.is_expires" -->
		<z-paging unit="rpx" class="normal-paging" v-model="dataList" @query="queryList" safe-area-inset-bottom ref="paging" :fixed="false">
			<!-- <template #refresher="{refresherStatus}">
				<view class="Grid Grid--center Grid--justifyCenter text-center text-xs text-white" style="width: 100vw; height: 100%; background-color: #0DA25F;">
					<view v-if="refresherStatus == 0" class="Media Media--center Media--justifyCenter">
						<view></view>
						<view class="Media-body">继续下拉刷新</view>
					</view>
					<view v-if="refresherStatus == 1" class="Media Media--center Media--justifyCenter">
						<view></view>
						<view class="Media-body">松开立即刷新</view>
					</view>
					<view v-if="refresherStatus == 2" class="Media Media--center Media--justifyCenter">
						<view></view>
						<view class="Media-body">正在刷新...</view>
					</view>
				</view>
			</template> -->
			<view class="analysis-box relative">
				<Item v-for="(item, index) in dataList" :key="index" :item="item" />
			</view>
		</z-paging>
		<!-- <view v-else class="relative" style="padding-top: 80rpx;">
			<u-image :src="bg_1" width="750rpx" height="1010rpx" mode="aspectFill"></u-image>
			<view class="text-center" style="position: absolute; top: 0; left: 0; width: 750rpx; height: 1010rpx; padding-top: 40%;">
				<view v-if="!token" style="text-align: center; top: 30%; width: 160rpx; padding: 15rpx 0; background: #0DA25F; color: #ffffff; font-size: 12px; border-radius: 40rpx; margin: 0 auto;" @click="goLogin">立即登录</view>
				<view v-else style="text-align: center; top: 30%; width: 160rpx; padding: 15rpx 0; background: #0DA25F; color: #ffffff; font-size: 12px; border-radius: 40rpx; margin: 0 auto;" @click="renew">申请续期</view>
				<view v-if="!token" class="text-xs" style="color: #222222; width: 100%; padding: 20rpx 0;">您暂未登录，登录后即可获得比赛分析</view>
				<view v-else class="text-xs" style="color: #222222; width: 100%; padding: 20rpx 0;">您的账号已过有效期，请申请续期后继续使用</view>
			</view>
		</view> -->
		<u-modal :show="isRenew" title="告知" content='续期申请已提交,请耐心等待~' @confirm="isRenew = false"></u-modal>
	</view>
</template>

<script>
	import dayjs from 'dayjs'
	import {
		externalInterfacePost
	} from "@/service/api/flyio";
	import {
		mapState
	} from "vuex";
	import {
		analysis
	} from '@/service/index.js'
	import Item from './cps/item.vue'
	import bg_1 from '@/static/image/bg_1.png'

	export default {
		name: 'analysis',
		components: {
			Item
		},
		props: {
			visible: {
				type: Boolean,
				default: false
			},
		},
		watch: {
			visible() {
				this.visible && this.initData()
			}
		},
		computed: {
			...mapState({
				userInfo: state => state.login.userInfo,
				token: state => state.login.token
			})
		},
		data() {
			return {
				bg_1,
				dataList: [],
				isLogin: false,
				isRenew: false
			}
		},
		onReady() {
			// 如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			// this.$refs.uForm.setRules(this.rules)
		},
		created() {

		},
		mounted() {
			this.initData()
		},
		methods: {
			async initData() {
				try {
					
				} catch (error) {}
			},
			async queryList(pageNo, pageSize) {
				try {
					const {
						data: {
							list,
							total
						}
					} = await analysis({
						page: pageNo,
						limit: pageSize,
						date: ''
					})
					this.$refs.paging.complete(list || []);
				} catch (e) {
					// TODO handle the exception
				}
			},
			goLogin() {
				uni.navigateTo({
					url: `/pages/login/login`
				})
			},
			async renew() {
				try {
					this.$showModal('是否向管理员申请续期?', () => {
						this.isRenew = true
					})
				} catch (e) {}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.analysis {
		height: calc(100vh - 280px);
		&::before {
			position: absolute;
			content: '';
			top: -20rpx;
			left: 0;
			width: 100%;
			height: 80rpx;
			background-color: #0DA25F;
		}
	}
	.analysis-box {
		z-index: 1;
		& > .an-item {
			// margin-bottom: 20rpx;
		}
		& > .an-item:first-child {
			border-radius: 30rpx 30rpx 0 0;
		}
	}
</style>